﻿using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;
using AjaxControlToolkit;
using System.Web.UI.HtmlControls;

[assembly: System.Web.UI.WebResource("AjaxControlToolkit.DisableButton.DisabledButtonBehavior.js", "text/javascript")]

namespace AjaxControlToolkitCustom
{
	[Designer(typeof(DisabledButtonDesigner))]
	[ClientScriptResource("AjaxControlToolkit.DisabledButtonBehavior", "AjaxControlToolkit.DisableButton.DisabledButtonBehavior.js")]
	[TargetControlType(typeof(TextBox))]
	[System.Drawing.ToolboxBitmap(typeof(DisabledButtonExtender), "DisableButton.ToggleButton.ico")]
	public class DisabledButtonExtender : ExtenderControlBase
	{
		protected HtmlGenericControl htmlArea;

		[ExtenderControlProperty]
		[DefaultValue("")]
		[IDReferenceProperty(typeof(Button))]
		public string TargetButtonID
		{
			get
			{
				return GetPropertyValue("TargetButtonID", "");
			}
			set
			{
				SetPropertyValue("TargetButtonID", value);
			}
		}

		[ExtenderControlProperty]
		[DefaultValue("")]
		[IDReferenceProperty(typeof(Label))]
		public string TargetLabelID
		{
			get
			{
				return GetPropertyValue("TargetLabelID", "");
			}
			set
			{
				SetPropertyValue("TargetLabelID", value);
			}
		}

		[ExtenderControlProperty]
		[DefaultValue("")]
		[IDReferenceProperty(typeof(Label))]
		public string TargetDivID
		{
			get
			{
				return GetPropertyValue("TargetDivID", "");
			}
			set
			{
				SetPropertyValue("TargetDivID", value);
			}
		}


		[ExtenderControlProperty]
		[DefaultValue("")]
		public string DisabledText
		{
			get
			{
				return GetPropertyValue("DisabledText", "");
			}
			set
			{
				SetPropertyValue("DisabledText", value);
			}
		}

		protected HtmlGenericControl CreateEditorArea()
		{
			HtmlGenericControl area = new HtmlGenericControl("div");
			area.ID = TargetDivID;
			area.Style["width"] = "140px";
			area.Style["height"] = "20px";
			area.Style["background-color"] = "#00cccc";

			return area;
		}

		protected HtmlGenericControl CreateHtmlArea()
		{
			htmlArea = CreateEditorArea();
			return htmlArea;
		}

		protected override void CreateChildControls()
		{
			base.CreateChildControls();
			this.Controls.Add(CreateHtmlArea());
		}
	}
}

